package com.example.chenduoyun.safe.utils;

import java.security.MessageDigest;

/**
 * @author by created chen cloudy 2018/9/10 9:39
 **/

public class Md5Util {
    public static String encoder(String psd){
        try{
            psd=psd+"safe";
            MessageDigest digest = MessageDigest.getInstance("MD5");
            byte[] bs=digest.digest(psd.getBytes());
            StringBuffer stringBuffer = new StringBuffer();
            for(byte b:bs){
                int i=b&0xff;
                String hexString = Integer.toHexString(i);
                if(hexString.length()<2){
                    hexString+="0";
                }
                stringBuffer.append(hexString);
                return String.valueOf(stringBuffer);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return "";
    }


}
